package com.bdqn.t382.service.impl;

import com.bdqn.t382.mapper.HotSpotConsultationMapper;
import com.bdqn.t382.pojo.HotSpotConsultation;
import com.bdqn.t382.pojo.Informations;
import com.bdqn.t382.pojo.Page;
import com.bdqn.t382.pojo.Replies;
import com.bdqn.t382.service.HotSpotConsultationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HotSpotConsultationServiceImpl implements HotSpotConsultationService {
    @Autowired
    HotSpotConsultationMapper hotSpotConsultationMapper;

    @Override
    public Page getPage(Integer pageNo, Integer pageSize) {
        Page page = new Page();
        try {
            page.setPageNo(pageNo);//当前页
            page.setPageSize(pageSize);//每页显示的数据量
            Long total = hotSpotConsultationMapper.count();//总记录数
            page.setTotalCount(total.intValue());
            int offset = (pageNo - 1) * pageSize;// 计算偏移量
            List<Informations> list = hotSpotConsultationMapper.getPage(offset, pageSize);
            page.setList(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return page;
    }

    @Override
    public Long count() {
        return hotSpotConsultationMapper.count();
    }

    @Override
    public List<HotSpotConsultation> getHotSpotConsultation(Integer id) {
        return hotSpotConsultationMapper.getHotSpotConsultation(id);
    }

    @Override
    public int insertReplies(Replies replies) {
        return hotSpotConsultationMapper.insertReplies(replies);
    }

    @Override
    public int updateInformations(Informations informations) {
        return hotSpotConsultationMapper.updateInformations(informations);
    }

    @Override
    public int deleteInformations(Integer id) {
        return hotSpotConsultationMapper.deleteInformations(id);
    }

    @Override
    public int deleteReplies(Integer infoId) {
        return hotSpotConsultationMapper.deleteReplies(infoId);
    }
}
